<?php

class HomeController extends GeanyController {

   // <editor-fold defaultstate="collapsed" desc="STATIC & PRIVATE VARIABLE DECLARATION">
    private $validator;
    const _FUNCTION_ID = 'usergroup';
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="CONSTRUCTOR">
  
    public function __construct(){
        parent::__construct();
        $this->loadDefaultValue();
        $this->loadServices();
        $this->validator = null;
    }
    
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="ACTION-HANDLER">
    public function index(){
        if (!$this->isLogin()){ return Redirect::to('login'); }
        if (!$this->isAllowAccess()){ return Redirect::to('forbidden'); }
//        if (strtoupper($this->UserInformation()->getGroup()->getId())=='ADMINISTRATOR'){
//            return Redirect::to('admin');
//        } else if (strtoupper($this->UserInformation()->getGroup()->getId())=='LEADER'){
//            return Redirect::to('leader');
//        } else if (strtoupper($this->UserInformation()->getGroup()->getId())=='EMPLOYEE'){
//            return Redirect::to('employee');
//        }
        
        return Redirect::to('blank');
    }

    public function admin(){
        if (!$this->isLogin()){ return Redirect::to('login'); }
        if (!$this->isAllowAccess()){ return Redirect::to('forbidden'); }
    
        return View::make('home/admin');
    }
    
    public function leader(){
        if (!$this->isLogin()){ return Redirect::to('login'); }
        if (!$this->isAllowAccess()){ return Redirect::to('forbidden'); }

        return View::make('home/leader');
    }
    
    public function employee(){
        if (!$this->isLogin()){ return Redirect::to('login'); }
        if (!$this->isAllowAccess()){ return Redirect::to('forbidden'); }

        return View::make('home/employee');
    }
    
    public function blank(){

        return View::make('home/blank');
    }
    
    
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="PRIVATE-FUNCTION">
    
    private function loadDefaultValue(){
        $this->setFunctionId(self::_FUNCTION_ID);
        $this->page_data['_MODULE_NAME'] = $this->getFunctionName();
    }

    private function loadServices(){
        
    }
    
    // </editor-fold>
    
}
?>